package org.uugu.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.uugu.service.NewsManager;
import org.uugu.service.UsersManager;
import org.uugu.service.WishesManager;

  
@Component("index")
@Scope("prototype")   
public class IndexAction extends BaseAction {  
   
    private UsersManager usersManager;
    private WishesManager wishesManager;
    private NewsManager newsManager;
    private List wishes;
    private List news;
    private List notes;
    private List videos;
    private List donates;
    private List mans;
    private String key;
    
    public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public UsersManager getUsersManager() {
		return usersManager;
	}
    @Resource
	public void setUsersManager(UsersManager usersManager) {
		this.usersManager = usersManager;
	}
  
    public WishesManager getWishesManager() {
		return wishesManager;
	}
    @Resource
	public void setWishesManager(WishesManager wishesManager) {
		this.wishesManager = wishesManager;
	}
	public NewsManager getNewsManager() {
		return newsManager;
	}
	@Resource
	public void setNewsManager(NewsManager newsManager) {
		this.newsManager = newsManager;
	}
	public List getWishes() {
		return wishes;
	}
	public void setWishes(List wishes) {
		this.wishes = wishes;
	}
	public List getNews() {
		return news;
	}
	public void setNews(List news) {
		this.news = news;
	}
	public List getNotes() {
		return notes;
	}
	public void setNotes(List notes) {
		this.notes = notes;
	}
	public List getVideos() {
		return videos;
	}
	public void setVideos(List videos) {
		this.videos = videos;
	}
	public List getDonates() {
		return donates;
	}
	public void setDonates(List donates) {
		this.donates = donates;
	}
	
	
	public List getMans() {
		return mans;
	}
	public void setMans(List mans) {
		this.mans = mans;
	}
	@Override
	public String execute() throws Exception {  
		try{
			wishes = this.wishesManager.listPassWishesByNum(8);
			news = this.newsManager.listNewsByNumAndItem(8, 1);
			notes = this.newsManager.listNewsByNumAndItem(8, 2);
			videos = this.newsManager.listNewsByNumAndItem(8, 3);
			donates = this.newsManager.listNewsByNumAndItem(8, 4);
			mans = this.newsManager.listNewsByNumAndItem(8, 5);
			return "index"; 
		}catch(Exception e){
			return "error";
		} 
    }  
	
	public String search() throws Exception {  
		try{
			news = this.newsManager.listAllSearchNews(key);
			return "searchResult"; 
		}catch(Exception e){
			return "error";
		} 
    }  
    
} 
